home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: MegaDisc / MegaDisc 45 (1996-03)(MegaDisc Digital Publishing)(AU)(Disk 1 of 2)[WB].zip / MegaDisc 45 (1996-03)(MegaDisc Digital Publishing)(AU)(Disk 1 of 2)[WB].adf / arexx / Extensions.txt / Extensions.txt
Text File  |  1996-01-23  |  23KB  |  502 lines

  1.  
  2.   
  3.                                    
  4.             ZedREXX and varexx     
  5.                                       by John Collett
  6.            First Impressions of    
  7.           Two Extensions to ARexx    
  8.                                    
  9.  
  10.     The absence of a Graphical User Interface in ARexx has always
  11.     appeared to me to be one of its surprising features, and in the past
  12.     we have had to use libraries such as 'rexxarplib.library' to enable
  13.     us to add windows, gadgets, etc. to our ARexx programs.  Now another
  14.     kind of interface has appeared, responsive, for example, to different
  15.     fonts, with new categories of user gadgets, and adding a different
  16.     kind of graphical interface to ARexx programs.
  17.  
  18.     The two programs I shall discuss here both offer such a GUI interface
  19.     to ARexx, but my experiences with them are very different.
  20.  
  21.     First I spotted ZedREXX, published by Reality Check, Inc. :
  22.     
  23.        A REXX Language Extension that adds sophisticated
  24.        Graphical User Interface capabilities using an
  25.        easy-to-use yet extremely powerful syntax.
  26.  
  27.     It looked promising.  I read the intro etc. and I got the demo to
  28.     work.  So I thought it was an idea worth pursuing.  I sent off my
  29.     money, and received the disk and docs of a registered user, and a
  30.     covering letter.  There were only about 20 pages of docs, and I'll
  31.     quote briefly from the letter :
  32.  
  33.        The preliminary version of the printed manual only shows
  34.        the commands and options that ZedREXX supports. When the
  35.        final version is completed, which will include tutorials
  36.        and special How-To sections, you will receive the update
  37.        at no additional charge.
  38.  
  39.     I waited months for the update. I sent a enquiry.  I waited.  I sent
  40.     a reminder.  I'm still waiting.  They have not even had the courtesy
  41.     to acknowledge my mail.
  42.  
  43.                Bye bye, ZedREXX.      Hello, varexx        
  44.        
  45.     There are 'Charts' available through aminet, where we can look up
  46.     which programs are in the current top ten - the most frequently
  47.     looked at or down-loaded files. That was where I first spotted
  48.     'varexx', by Andrew Cook.  From the file 'varexx.readme' :
  49.  
  50.                A GUI system for Arexx. v1.4
  51.                Author:   amc93el@soton.ac.uk (Andy Cook)
  52.      Requires: OS 2.04+, Arexx, Gadtoolsbox is required to create new GUI's 
  53.                but is not needed to use other peoples scripts.
  54.                Reqtools.library and arexxport.library are needed (and both
  55.                included).
  56.      Version:  1.4
  57.  
  58.      Varexx is a program that allows you to control graphical user
  59.      interfaces (GUI's) from arexx scripts. The program loads the .gui 
  60.      files that are saved by Jan van den Baard's Gadtoolsbox program and 
  61.      displays them on the screen.
  62.     
  63.      Arexx scripts can then send messages to a port and control the actions
  64.      of the Gui. The script can read and set the contents of each of the 
  65.      gadgets, resize the window and such like.
  66.  
  67.     I down-loaded it straight away, and entered directly into that kind of
  68.     friendly, supportive computing environment that we all dream of. 
  69.     Andrew invited communication, and I communicated.  He replied
  70.     instantly, in a full and helpful way, and we had a quick series of
  71.     email exchanges - almost as if he was looking over my shoulder and
  72.     prompting me as to what to do next.  Everything worked beautifully. 
  73.     I even got, on December 24, a super Christmas greeting from Andrew,
  74.     in which he expressed the hope that he would be hearing again from me
  75.     in the new year.  He will.
  76.  
  77.     Just look at the contrast
  78.     
  79.             You pay for ZedREXX, and on-going support is zero.    
  80.     
  81.             Varexx is free, and the author goes out of his way    
  82.             to be supportive and friendly.                        
  83.  
  84.     Ah yes, you may say, but how do the two systems compare in what they
  85.     do and how they do it?   They seem to be covering similar if not
  86.     identical areas, but I cannot make an honest and informed comparison,
  87.     because I have seen so little output from ZedREXX.  The little I have
  88.     seen suggests that I shall survive without using it.
  89.     
  90.     ----
  91.     Late insertion I have just spotted EasyRexx in aminet, and had
  92.     a quick look at it. It may be similar to the two extensions I am
  93.     discussing, but I haven't examined it closely.  (Its author is
  94.     certainly not going to die of modesty.)
  95.     ----
  96.     
  97.     Meanwhile my exploration of 'varexx' gets more interesting as I go. 
  98.     I still have much ground to cover but, after listing the samples and
  99.     explaining a few preliminaries, I'll illustrate the potential of this
  100.     program with some of the 'first step' programs which I have pieced
  101.     together. 
  102.  
  103.      Sample programs provided 
  104.     
  105.     In the 'scripts' directory of version 1.4 of varexx there are the
  106.     following programs:
  107.  
  108.       Demo.rexx      An excellent straight-through demo of what varexx can do
  109.     
  110.       TestGUI.rexx   For preliminary inspection of any guis you create.
  111.                      Takes the path and name of the gui as an argument,
  112.                      e.g. rx TestGUI.rexx rexx:gui/sample_gui
  113.                      If no arg is given, a file requester appears.
  114.     
  115.       TestGUI2.rexx  Also for inspecting guis, but in cases where you
  116.                      have more than one window in a file, this lets you choose 
  117.                      which particular window file you wish to inspect.
  118.  
  119.       Address.rexx   An address book.
  120.     
  121.     Also, in the full docs to varexx, there is an example of a script
  122.     outline.  I lifted it out, called it vasample.rexx, and have used it
  123.     as a basis for much of my own exploratory varexx work.  It has been a
  124.     good foundation for learning.
  125.  
  126.      Preliminaries 
  127.     
  128.     When I had down-loaded 'varexx' and had my first look at its
  129.     requirements, I noted that the graphics files it uses have to be
  130.     created by Gadtoolsbox.  I didn't have GTB, but found it on aminet,
  131.     and down-loaded it.  Like all programs obtained from that source, it
  132.     had to be unpacked from the '.lha' format.  As I watched the unpacking
  133.     list unroll on the screen, all 106 files of it, my heart fell.  Here
  134.     was a giant to be mastered, before I could even start on 'varexx', 
  135.     and in a fit of impatience I sent moaning and complaining mail to
  136.     Andrew Cook.  He calmed me down in his very kind reply.  Here is an
  137.     extract from his explanations :
  138.     
  139.        GTB is a program that lets you draw graphic user interfaces on the
  140.        screen with a mouse. You place a button on the screen and GTB works
  141.        out the pixel counts. There are options to do things like spreading
  142.        gadgets out evenly and aligning them with each other and such like.
  143.        (but don`t worry about that.)
  144.  
  145.     Andrew also provided a step-by-step guide of the kind I love, and
  146.     often need.  Here are the steps, largely as sent, but slightly
  147.     extended in the light of my subsequent explorations.
  148.  
  149.     From the very start, there are four stages to getting a gui to appear
  150.     when you run an ARexx program :
  151.  
  152.          [A]  Installing at least the minimum of Gadtoolsbox
  153.          [B]  Using Gadtoolsbox to create a gui
  154.          [C]  Launching 'varexx'
  155.          [D]  Using your gui in an ARexx program
  156.      
  157.  
  158.      [A] The minimum of Gadtoolsbox needed for 'varexx' 
  159.         
  160.     A.1  Copy 'nofrag.library' and 'gadtoolsbox.library' into libs:
  161.  
  162.     A.2  Delete everything else in the Gadtools package except the
  163.          Gadtoolsbox program itself, it's icon and the doc files. (Don't
  164.          you just love it when you can do things like that?)
  165.     
  166.      
  167.      [B] The first exploratory use of Gadtoolsbox 
  168.     
  169.     B.1  Run the program
  170.  
  171.     B.2  You will see an open window entitled 'Work Window'
  172.  
  173.     B.3  Use the menus. Select the second menu (Gadgets), its first item
  174.          (KIND), and 'BUTTON' from the sub-menu of 'KIND'.
  175.  
  176.     B.4  With the left mouse button, drag out a rectangle in the window. 
  177.          A requester will appear when you release the button.
  178.  
  179.     B.5  Type a name (say, BUTTON) in the box labelled 'LABEL' and some
  180.          text into the text string gadget. This text will appear in the button
  181.          in the window.
  182.  
  183.     B.6  Use the first menu 'Save As' option and save the file somewhere.
  184.          'Rexx:gui/Button1.gui' is suggested.
  185.     
  186.     Hint 1 The docs make it clear, but it's easy to overlook,
  187.     that varexx doesn't like gui files to be crunched - refuses to work
  188.     if they are - and the copy of GTB as you down-load it may have the
  189.     Crunch option set to ON.  Do this to check : Before you leave
  190.     Gadtoolsbox, select Preferences from the first menu.  If the Crunch
  191.     option is shown as being ON, with a tick, then click on it to turn it
  192.     off, save the prefs, and then re-save your trial gui.
  193.  
  194.     Hint 2.  Already I have realised the value of fixing a
  195.     regular 'gui' location for my work.  In imitation of other 'varexx'
  196.     examples I have seen, I now put all products from Gadtoolsbox into
  197.     a specifically created directory 'rexx:gui/'.
  198.  
  199.     
  200.       [C]  Launch 'varexx' 
  201.     
  202.     C.1 Go to a shell
  203.  
  204.     C.2 Find and run 'varexx'; something like "work:Varexx/bin>
  205.          varexx", or simpler, as Andrew suggests, just make sure that a
  206.          copy of varexx is in your current working directory.
  207.  
  208.     
  209.       [D]  Use your gui in an ARexx program 
  210.  
  211.     D.1 Find the 'testgui.rexx' script and run it. Like this :
  212.          From shell :
  213.           Line 1 : varexx/scripts
  214.           Line 2 : rx testgui.rexx rexx:gui/Button1.gui
  215.     
  216.     That is, when you run a varexx script from a shell, it expects as an
  217.     argument, after its own name, the full path and name of the gui which
  218.     you saved in [B.6] above. 
  219.  
  220.     D.2 Your window should appear, that is, the one you designed in
  221.          Gadtoolsbox.  
  222.     
  223.     Click on the Button which you created. It will send a message to the
  224.     shell window from which you ran 'testgui.rexx'. That message will be
  225.     whatever LABEL you gave the button when you created it. 
  226.  
  227.     That's the crucial point, the central idea which will be extended below.
  228.     A message is being passed from one window to another.
  229.  
  230.   
  231.     D.3  Close the window to exit.
  232.     
  233.  
  234.      My explorations 
  235.     
  236.      1  Stretching testgui.rexx and vasample.rexx 
  237.     
  238.     GadToolsBox was not the awesome monster I had feared, but an easy
  239.     and very versatile way of creating GUI elements you wish to use. It
  240.     has heaps of menus, most of which I haven't even tried out yet. 
  241.     Don't be afraid of it. Just explore.  
  242.     
  243.     The nice examples included with varexx contain 'testgui.rexx' already
  244.     referred to above.  My first tentative solo steps simply used that
  245.     program with gadgets other than a button, and then with several
  246.     different gadgets in one window. To get used to it, try selecting
  247.     different gadget types, to create something like this (excuse the
  248.     rough graphics here) :
  249.  
  250.                                                _____    
  251.                   Check box [  ]      Button  |     |   
  252.                              _____            |_____|   
  253.                   Integer   [_____]                     
  254.                              _______                    
  255.                   Cycle     [@|_____]                   
  256.                                                         
  257.     
  258.     Depending on what labels you insert, and what you then do with the
  259.     gadgets when you run 'testgui.rexx', you should get this sort of
  260.     feedback to your actions being displayed in your shell window :
  261.  
  262.          CHECK1 TRUE
  263.          BUTTON1 
  264.          INTEGER 42567
  265.          CYCLE 1
  266.          CYCLE 2
  267.          CYCLE 0
  268.          CLOSEWINDOW 
  269.     
  270.     I then duplicated this output using vasample.rexx instead of
  271.     testgui.rexx, just to feel that I was gaining some independence, and
  272.     soon started finding out how flexible and forgiving varexx is.  For
  273.     example, despite what I said above :
  274.  
  275.     (1) You don't have to launch varexx before running an ARexx
  276.     program which uses it.  Instead, you can include a patch in the
  277.     program to check whether or not 'varexx' has already been launched
  278.     and act accordingly.
  279.     
  280.       if show( 'p', 'VAREXX' ) ~= 1 then do
  281.         address command 'run Varexx'
  282.         address command 'waitforport VAREXX'      *
  283.         end
  284.   
  285.     * Andrew's version of this line was : waitforport VAREXX
  286.       I found that the extended version I have shown here worked better.
  287.       I mentioned this to Andrew. He agrees.
  288.  
  289.     (2) You don't have to add a gui path and name as an argument
  290.     when using testgui.rexx.  If you don't, a requester prompts you for
  291.     the filename. Of course in your own developmental work, the gui path
  292.     and name are probably predefined like this :
  293.  
  294.          'load rexx:gui/FourTypes.gui WINDOWPORT'
  295.     
  296.     Or early in the program, for convenience :
  297.        gui_name = rexx:gui/FourTypes.gui
  298.     
  299.     And then, when needed :   
  300.        'load ' gui_name ' WINDOWPORT'
  301.  
  302.     In these various explorations, as soon as I felt I was beginning to
  303.     get some sort of control over what was happening, I got slightly more
  304.     ambitious.
  305.  
  306.      2   A 'rexxarplib.library' window AND varexx 
  307.     
  308.     I opened a rexxarplib window, with a plain old-fashioned gadget. 
  309.     When I click on it, a varexx gui appears, inviting whatever
  310.     user-input is required.  It sounds trivial, but it has enormous
  311.     potential, and was significant for me because it confirmed that
  312.     messages can be passed between the two types of window.
  313.  
  314.     Instead of the confirming feedback messages such as 
  315.     CHECK1 TRUE   BUTTON1       INTEGER 42567 CYCLE 1       CYCLE 2      
  316.     CYCLE 0       CLOSEWINDOW  
  317.     appearing in the CLI window, they are passed back from a varexx-using
  318.     function to the parent window, where they can be displayed however
  319.     I choose, or not. Any of them can be used as the basis for
  320.     more complex actions in the parent window....
  321.  
  322.      3  Using instructions returned from varexx
  323.     
  324.     I created a Gadtoolsbox window something like this, with a string
  325.     entry gadget, an x and y slider to fix the position of the string,
  326.     and a colour selector gadget to determine its colour :
  327.     
  328.               _______________________________________   
  329.        Entry [_______________________________________]  
  330.               ______________           ______________   
  331.        x pos [_ ____________]   y pos [_ ____________]  
  332.                  _________________                      
  333.        Text     [ (samples here)  ]                     
  334.        colour   [_________________]                     
  335.                                                         
  336.     
  337.     When the varexx window is closed, the data is passed back to the
  338.     parent window, and used to place the string, as specified, in that
  339.     window.
  340.  
  341.     There are many more possible elements for inclusion in the varexx
  342.     window, and dozens of user interactions which could be varexx-
  343.     controlled, such as :
  344.  
  345.      What shape do you want to draw?     
  346.      What IFF image do you want to load?
  347.      What new gadget do you want to add? 
  348.      Where?  What colour?  How many?   And so on.
  349.  
  350.       4  Access to DosMan
  351.  
  352.     DosMan is available from aminet:util/wb/DosMan121.lha
  353.  
  354.     When Peter Bagnato put DosMan together, he used amiga.guide as the
  355.     presenter of a complete DOS manual.  Two other methods of
  356.     presentation were discussed and tried, and they both worked
  357.     smoothly.
  358.  
  359.      - A small plain ARexx program using the FileList() function
  360.      - A HyperBook unit using that system's List and Note features
  361.     
  362.     The new challenge was at least to match their performance using
  363.     varexx.  This time, the kind of gadget put into a gui via
  364.     Gadtoolsbox was a ListView.
  365.     
  366.     Stages within the program which use it are as follows :
  367.        
  368.        Set 'options results'
  369.        If necessary, open libraries and load varexx
  370.        Set 'address VAREXX'
  371.        Open a port
  372.        Load the gui
  373.        Set host to port for gui
  374.      
  375.        Build the list :
  376.         A copy of the 'man' directory into Ram: via 'list' 
  377.         Open the list file.
  378.         Read line by line from the list file, and assign each item to an
  379.           array.  That array will be read into the 'ListView' gadget.   
  380.         Close the list file.
  381.        
  382.        Display the window
  383.        Use varexx 'setlist' command to fill the list
  384.        
  385.        Start a loop, until the user closes the window 
  386.           Wait for a message
  387.           Get the message. Examine it.
  388.           If it is not empty, parse it.
  389.     
  390.             If the first word is DOSLIST,
  391.             then the second word is the target 'man' file 
  392.             Use a viewer (like FullView) to display it.
  393.        
  394.             If the message is CLOSEWINDOW
  395.             then unload the gui file 
  396.             close the port
  397.             exit
  398.        
  399.     I am not going to try to render every detail of the output here, but
  400.     the diagram below is intended to suggest an outer window (the varexx
  401.     window), an inner 'List' gadget, and a black slider.  
  402.     
  403.     Whichever list item you click on, the required text is displayed 
  404.     (in less than 2 seconds on my machine).
  405.  
  406.                          ___________________ 
  407.                         |_|_DosMan______|_|_|
  408.                         |________________ | | 
  409.                         ||AddBuffers   | || | 
  410.                         ||AddDataTypes | || | 
  411.                         ||Alias        | || | 
  412.                         ||Ask          | || | 
  413.                         ||Assign       | || | 
  414.                         ||Asterix(*)   | || | 
  415.                         ||Avail        | || | 
  416.                         ||BackTick     | || | 
  417.                         ||BaseName     | || |
  418.                         ||Binddrivers  | || | 
  419.                         ||Break        | || | 
  420.                         ||CD           | || |
  421.                         ||ChangeTaskPri| || | 
  422.                         ||Cmpas        | || | 
  423.                         ||Conclip      | || |
  424.                         ||Copy         | || | 
  425.                         ||CPU          | || | 
  426.                         ||Date         | || |
  427.                         ||Delete       | || | 
  428.                         ||Dir          | || | 
  429.                         ||_____________|_||_|
  430.                         |_________________|_|
  431.                        
  432.     As you pull the slider down, the list scrolls up, and if you go all
  433.     the way, you will reach the last few of more than 90 items.:
  434.                         ..             . .. .
  435.                         ..             . .. .
  436.                         ||Wait         | || |
  437.                         ||Which        | || |
  438.                         ||Why          | || |
  439.                         ||_____________|_||_|
  440.                         |_________________|_|
  441.                     
  442.     My access to DosMan has been easy ever since I got it, and varexx has
  443.     given me another way of arranging for that to be so.
  444.  
  445.  
  446.     5  Access to Pix, my fastest yet
  447.  
  448.     During recent weeks I've been exploring ways of reducing the time it
  449.     takes to screen a JPEG or similar picture.  I have found that while
  450.     FJPEG or Viewtek perform well, especially the former with JPEG files,
  451.     I can get an even faster screening by using QuickGrab, which produces
  452.     picture files QuickGrab.000, QuickGrab.001, and so on in Ram:. If
  453.     these are renamed, saved in a directory, and then Viewtek is used,
  454.     they screen very rapidly, practically instantly.
  455.  
  456.     I have combined this strategy with a variation on the Dosman approach
  457.     described above and, just for variety, did it using a set of button
  458.     gadgets instead of a list.  For each button gadget entered in the
  459.     gui, the LABEL and the TEXT are identical.  This means that whatever
  460.     gadget I click on, that text of the gadget is passed as 'class' to
  461.     a Viewtek command, and the picture of that name appears.
  462.     
  463.         if class ~= closewindow then address command 'vt pix/' || class
  464.         else leave    
  465.  
  466.     Using gadgets does, of course, put a high upper limit on how many can 
  467.     be handled comfortably, and in fact, since writing these paragraphs, I
  468.     have changed the method of access from gadgets to a file lister.
  469.  
  470.      6  A varexx version of ToolManager
  471.     
  472.     A possible new direction became clear. If I could use varexx to
  473.     draw up a list to view texts, or to assemble gadgets to choose a
  474.     picture, it was going to be quite easy to arrange a display of
  475.     buttons, gadgets, lists, or whatever, to launch any of the tools I
  476.     use in my day-to-day Amiga work : one of them to run my terminal
  477.     program, another to run Browser, and so on, for IconEdit, palette,
  478.     Calculator, QED, DPaint, AmigaVision, HyperBook .. whatever I want
  479.     to use.      
  480.     
  481.     It's up and running, now, and it's great!  I can tinker with the 
  482.     layout and appearance to my heart's content, and change it easily 
  483.     at any time. The zoom gadget on the varexx window will iconify it
  484.     when I want it out of the way.  
  485.    
  486.      Conclusion 
  487.     
  488.     I've still got heaps of exploring to do with Gadtoolsbox and varexx,
  489.     and I'm looking around for a major application to put them and me
  490.     really to the test.
  491.  
  492.     Meanwhile, many thanks to Andrew Cook for 'varexx', and for his
  493.     kind and patient responses to my communication.
  494.     
  495.     And many thanks to Peter Bagnato, for 'DosMan' and much more.
  496.  
  497.     
  498.     Hamilton, New Zealand  January 1996
  499.     
  500.                        ------------------------------
  501.  
  502.